<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function arr(strs) {
      let ret = 0
      for (let i = 0; i < strs[0].length; i++) {
        const chs = strs.map(s => s[i])
        if (chs.join('') !== chs.sort().join('')) {
          ret++
        }
      }
      return ret
    };
    console.log(arr(["cba", "daf", "ghi"]));
  </script>
</body>

</html>